
package util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.Data;

@Data
public class PageUitl<T> {
		private  Integer pageNo;
		private Integer pageSize;
		private Integer rows;
		private  Integer pageTotal;
		private  List<T> list;
		
		private Map<String, T> map = new HashMap<>();
		
		public PageUitl(Integer pageNo, Integer pageSize, Integer rows) {
			
			this.pageSize = pageSize;
			this.rows = rows;
			//先算出总页数  
			this.pageTotal=this.rows%this.pageSize==0?this.rows/this.pageSize:(this.rows/this.pageSize)+1;
			//判断 pageNo 的几种情况
			if(pageNo==null){
				this.pageNo=1;
			}else if (pageNo<1) {
				this.pageNo=1;
			}else if (this.pageTotal==0) {
				this.pageNo=1;
			}else if (pageNo>this.pageTotal) {
				this.pageNo=this.pageTotal;
			}else {
				this.pageNo=pageNo;
			}
			
		}
		
		
		
		public List<T> getList() {
			return list;
		}

		public void setList(List<T> list) {
			this.list = list;
		}
		public Integer getPageNo() {
			return pageNo;
		}
		public void setPageNo(Integer pageNo) {
			this.pageNo = pageNo;
		}
		public Integer getPageSize() {
			return pageSize;
		}
		public void setPageSize(Integer pageSize) {
			this.pageSize = pageSize;
		}
		public Integer getRows() {
			return rows;
		}
		public void setRows(Integer rows) {
			this.rows = rows;
		}
		public Integer getPageTotal() {
			return pageTotal;
		}
		public void setPageTotal(Integer pageTotal) {
			this.pageTotal = pageTotal;
		}
	
		
		
		
		
		
		
}
